using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Diagnostics;
/// <summary>
/// Summary description for Calypso
/// </summary>
/// 
namespace Calypso
{
     public class CalypsoPage :  System.Web.UI.Page
    {
        public CalypsoPage()
        {
            this.PreInit += new EventHandler(CalypsoPage_PreInit);
        }
        /**
         * This applies master pages automaticly to each page depending on the permisions
         */
        void CalypsoPage_PreInit(object sender, EventArgs e)
        {
            string mp = null;
            mp = (String)Context.Application.Get("master-template");
            if (mp == null)
            {
                throw new Exception("masterpage can't be null");
            }
            Debug.Print("Trying to Apply MasterPage=" + mp);
            MasterPageFile = mp;
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            //Debug.Print("Calypso sender = " + Context.Application.Get("master-template"));
        }
    }
}
